package org.james.deleter.components;

import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Font;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class PopupWindow extends Stage {
	
	private Label label = new Label();
	private Button button = new Button("确定");
	private BorderPane root = new BorderPane();
	private HBox hbox1 = new HBox();
	private HBox hbox2 = new HBox();

	public PopupWindow(){
		super();
		this.initialize();
	}
	
	public PopupWindow(String text){
		super();
		label.setText(text);
		this.initialize();
	}
	
	private void initialize(){
		Scene scene=new Scene(root,400,60);
		label.setFont(new Font(20));
		hbox1.getChildren().add(label);
		hbox2.getChildren().add(button);
		
		hbox1.setAlignment(Pos.CENTER);
		hbox2.setAlignment(Pos.BASELINE_CENTER);
		HBox.setMargin(button, new Insets(0, 0, 10, 0));
		
		root.setTop(hbox1);
		root.setBottom(hbox2);
		this.setFullScreen(false);
		this.setResizable(false);
		this.initModality(Modality.APPLICATION_MODAL);  
		this.setScene(scene);
		this.setTitle("消息");
		
		button.setOnAction((evt) -> {
			this.close();
		});
	}
}
